package com.example.lcode.binary;

public class Question528 {

    int []weight = null;
    int []dynamicWeight = null;
    int weights = 0;

    public Question528(int[] w) {
        weight = new int[w.length];
        dynamicWeight = new int[w.length];
        for (int i = 0; i < w.length; i++) {
            weight[i] = w[i];
            dynamicWeight[i] = w[i];
            weights = weights + w[i];
        }
    }

    public int pickIndex() {
        int maxIndex = 0;
        int max = 0;
        for (int i = 0; i < dynamicWeight.length; i++) {
            if (max < dynamicWeight[i]) {
                max = dynamicWeight[i];
                maxIndex = i;
            }
        }
        dynamicWeight[maxIndex] = dynamicWeight[maxIndex] - weights;
        for (int i = 0; i < dynamicWeight.length; i++) {
            dynamicWeight[i] = dynamicWeight[i] + weight[i];
        }
        return maxIndex;
    }

    public static void main(String[] args) {

    }

}
